package com.ww.common.exception;

import com.ww.common.dtos.ResponseResult;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * 自定义全局异常处理类
 */
@RestControllerAdvice  //声明异常拦截   该注解把返回值转换json字符串
public class GlobalExceptionHandler {
    
    /**
     * 处理业务异常
     */
    @ExceptionHandler(value = LeadNewsException.class)
    public ResponseResult handleLeadNewsException(LeadNewsException e){
        return ResponseResult.errorResult(e.getStatus(),e.getMessage());
    }

    /**
     * 处理系统异常
     */
    //@ExceptionHandler(value = Exception.class)
    //public ResponseResult handleException(Exception e){
        //return ResponseResult.errorResult(500,e.getMessage());
  //  }
}

